/* 
 *	Copyright (C) 2009-2010 miaohua
 *	http://code.google.com/p/lrcshower/
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

// PlayerSettingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MusicBox.h"
#include "PlayerSettingDlg.h"


// CPlayerSettingDlg dialog

IMPLEMENT_DYNAMIC(CPlayerSettingDlg, CDialog)

CPlayerSettingDlg::CPlayerSettingDlg(SettingPage WhichPage, CWnd* pParent /*=NULL*/)
	: CDialog(CPlayerSettingDlg::IDD, pParent)
    , m_PageIdx(WhichPage)
{

}

CPlayerSettingDlg::~CPlayerSettingDlg()
{
}

void CPlayerSettingDlg::DoDataExchange(CDataExchange* pDX)
{
     CDialog::DoDataExchange(pDX);
     DDX_Control(pDX, IDC_PROP_AREA, m_PropPos);
}


BEGIN_MESSAGE_MAP(CPlayerSettingDlg, CDialog)
     ON_BN_CLICKED(IDC_ABOUT_BTN, &CPlayerSettingDlg::OnBnClickedAboutBtn)
     ON_BN_CLICKED(IDC_WINLRC_BTN, &CPlayerSettingDlg::OnBnClickedLrcBtn)
     ON_BN_CLICKED(IDC_DESKLRC_BTN, &CPlayerSettingDlg::OnBnClickedDesklrcBtn)
     ON_BN_CLICKED(IDC_SEARCHLRC_BTN, &CPlayerSettingDlg::OnBnClickedSearchlrcBtn)
     ON_BN_CLICKED(IDC_CANCEL_BTN, &CPlayerSettingDlg::OnBnClickedCancelBtn)
     ON_BN_CLICKED(IDC_RESTOREALL_BTN, &CPlayerSettingDlg::OnBnClickedRestoreAllBtn)
END_MESSAGE_MAP()


// CPlayerSettingDlg message handlers
BOOL CPlayerSettingDlg::OnInitDialog()
{
     CDialog::OnInitDialog();
     // Create property page
     m_AboutPage.Create(IDD_ABOUT_PAGE, this);   
     m_WinLrcPage.Create(IDD_WINLRC_PAGE, this);
     m_DeskLrcPage.Create(IDD_DESKLRC_PAGE, this);
     m_LrcSearchPage.Create(IDD_SEARCHLRC_PAGE, this);
     // Show the right setting page
     ShowSettingPage(m_PageIdx);

     return FALSE;
}

void CPlayerSettingDlg::ShowSettingPage(SettingPage PageIdx)
{
     // Get show position
     CRect Rect; 
     m_PropPos.GetClientRect(&Rect); 
     m_PropPos.MapWindowPoints(this, &Rect);
     Rect.top += 7;
     Rect.left += 1;
     Rect.bottom -= 1;
     Rect.right -= 1;
     // Move to show place
     if( !PageIdx ) 
          m_AboutPage.MoveWindow(&Rect); 
     else if( PageIdx&WinLrcPage ) {
          m_WinLrcPage.MoveWindow(&Rect); 
          GetDlgItem(IDC_WINLRC_BTN)->SetFocus();
     } else if( PageIdx&DeskLrcPage ) {
          m_DeskLrcPage.MoveWindow(&Rect);
          GetDlgItem(IDC_DESKLRC_BTN)->SetFocus();
     } else if( PageIdx&LrcSearchPage ) {
          m_LrcSearchPage.MoveWindow(&Rect);
          GetDlgItem(IDC_SEARCHLRC_BTN)->SetFocus();
     }
     // Show or hide
     m_AboutPage.ShowWindow(!PageIdx);
     m_WinLrcPage.ShowWindow(PageIdx&WinLrcPage ? TRUE : FALSE);
     m_DeskLrcPage.ShowWindow(PageIdx&DeskLrcPage ? TRUE : FALSE);
     m_LrcSearchPage.ShowWindow(PageIdx&LrcSearchPage ? TRUE : FALSE);
}

void CPlayerSettingDlg::OnBnClickedAboutBtn()
{
     ShowSettingPage(AboutPage);
}

void CPlayerSettingDlg::OnBnClickedLrcBtn()
{
     ShowSettingPage(WinLrcPage);
}

void CPlayerSettingDlg::OnBnClickedDesklrcBtn()
{
     ShowSettingPage(DeskLrcPage);
}

void CPlayerSettingDlg::OnBnClickedSearchlrcBtn()
{
     ShowSettingPage(LrcSearchPage);
}

void CPlayerSettingDlg::OnBnClickedCancelBtn()
{
     EndDialog(IDCANCEL);
}

void CPlayerSettingDlg::OnBnClickedRestoreAllBtn()
{
     
}
